package com.itheima.volitale.男孩和女孩;

public class Boy2 {
    public static void main(String[] args) {
        GrilThread2 gril2 = new GrilThread2();
        gril2.start();

        while (true){
            synchronized ("ab"){
                if (GrilThread2.money<10){
                    System.out.println("钱不是10万了");
                    break;
                }
            }
        }
    }
}

class GrilThread2 extends Thread{
    public static int money=10;

    @Override
    public void run() {
        try {
            Thread.sleep(10);
            money-=5;
            System.out.println("女孩数了一下，还剩"+money+"元");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}